<template>
  <div class="detail-product">
    <div @click="itemClick(item)" class="detail-product-item" v-for="item in productList" :key="item.id">
      <img :src="item.list_pic_url" alt="" />
      <div class="bottom">
        <p class="name">{{ item.name }}</p>
        <p class="price">{{ item.retail_price | filterPrice}}</p>
      </div>
    </div>
  </div>
</template>

<script>
// import { detailactions } from "@/network/detail";
export default {
  props: {
    productList: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  filters: {
    filterPrice(val) {
      return "¥" + val;
    },
  },
  methods: {
    // tiao到对应的路由上面去
    itemClick(item) {
      // let index = this.productList.findIndex((items) => items.id == item.id);
      // console.log(this.productList[index].id);
      // // let openId = localStorage.getItem("openId");
      // this.$router.push({
      //   path: "/detail",
      //   query: {
      //     id: this.productList[index].id,
      //     // openId,
      //   },
      // });
      //  location.reload()
      this.$emit('detailClick', item)
    }
  }
};
</script>

<style lang="scss" scoped>
.detail-product {
  display: flex;
  flex-wrap: wrap;
  margin: 0 10px 60px;
  justify-content: space-between;
  .detail-product-item {
    width: 49%;
    background-color: #fff;
    margin-bottom: 5px;
    img {
      width: 151px;
    }
    .bottom {
      margin-left: 10px;
      p {
        margin: 10px 0;
      }
      p.price {
        color: #f00;
      }
    }
  }
}
</style>